﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Thaire.Investment.Domains.Master;

namespace Thaire.Investment.Repository
{
    public class CreditAgencyRepo : BaseRepository<CreditAgency, int>
    {
        public CreditAgencyRepo(ISession session)
            : base(session)
        {
        }

        public string GetName(int? ID)
        {
            if (!ID.HasValue)
                return null;
            var data = GetByID(ID.Value);
            if (data != null)
            {
                return data.CreditAgencyIssue;
            }
            else
                return null;
        }

        public CreditAgency GetByRatingAndIssue(String rating,String issue)
        {
         return   _session.QueryOver<CreditAgency>().Where(x => x.CreditAgencyIssue == issue && x.CreditAgencyIssueRating == rating).List().FirstOrDefault();
        }
    }
}
